﻿using ClockInLearning.Db;
using ClockInLearning.Dto;
using ClockInLearning.Impl;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ClockInLearning.Controllers
{
    [ApiController]
    [Route("pointRegist")]
    [ServiceFilter(typeof(ApiFilter))]
    public class PointRegistController : Controller
    {
        private readonly PointsRegistApplication _application;

        public PointRegistController(AppDbContext context)
        {
            _application = new PointsRegistApplication(context);
        }

        [HttpPost("registAddRecord")]
        public async Task<ServiceResult> RegistAddRecord(PointsRegistRecordInputDto dto)
        {
            return await _application.RegistAddRecord(dto);
        }

        [HttpPost("registUseRecord")]
        public async Task<ServiceResult> RegistUseRecord(UsedPointRegistDto dto)
        {
            return await _application.RegistUseRecord(dto);
        }

        [HttpPost("query")]
        public async Task<ServiceResult<PageData<PointsRegistRecordOutputDto>>> Query(PageRequest<PointsRegistRecordQueryDto> request)
        {
            return await _application.Query(request);
        }

        [HttpPost("queryByMonth")]
        public async Task<ServiceResult<List<CalendarRegistRecordDto>>> QueryListByMonth(QueryMonthDto request)
        {
            return await _application.QueryListByMonth(request);
        }
    }
}
